package com.bw.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bw.service.GmallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author Lenovo
 * @date 2025年09月03日 8:57
 */
@RestController
public class GmallController {
    @Autowired
    private GmallService gmallService;

    @RequestMapping("/s1")
    public JSONObject select1(){
        JSONObject retult = new JSONObject();
        retult.put("status",0);
        retult.put("msg","");
        JSONObject data = new JSONObject();
        retult.put("data",data);

        JSONArray categories = new JSONArray();
        JSONArray series = new JSONArray();
        data.put("categories",categories);
        data.put("series",series);
        List<Map<String,Object>>maps=gmallService.select1();
        for (Map<String, Object> map : maps) {
            JSONObject row = new JSONObject();
            row.put("id",map.get("id"));
            row.put("name",map.get("name"));
            row.put("cta",map.get("cta"));
            categories.add(row);

        }
        return retult;
    }
}
